/*
 * RedPacketAssetMessageHolder.java
 * business
 *
 * Created by ChenTao on 2017/1/10.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.listview.viewholder;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.yidiandao.business.R;
import com.yidiandao.business.data.bean.Message;
import com.yidiandao.business.ui.widget.listview.ViewHolder;
import com.yidiandao.business.utils.ImageLoader;
import com.yidiandao.business.utils.TextRenderUtils;
import com.yidiandao.business.utils.UIUtils;

/**
 * 我的资产-红包消息-ViewHolder
 */
public class NormalAssetMessageHolder extends ViewHolder {

    private View viewUnRead;

    private ImageView ivImage;

    private TextView tvContent;

    private TextView tvDate;

    @Override
    protected void initView(View rootView) {
        viewUnRead = rootView.findViewById(R.id.view_un_read);
        ivImage = (ImageView) rootView.findViewById(R.id.iv_image);
        tvContent = (TextView) rootView.findViewById(R.id.tv_content);
        tvDate = (TextView) rootView.findViewById(R.id.tv_date);

        initRedPacketUI();
    }

    private void initRedPacketUI() {
        ImageLoader.loadLocalImage(mContext, ivImage, R.mipmap.ic_red_packet_asset_message);
    }

    @Override
    protected int getItemLayoutId() {
        return R.layout.item_normal_asset_message;
    }

    public void refreshTime(Message message) {
        tvDate.setText(message.getAddTime());
    }

    public void refreshUI(Message message) {
        tvContent.setText(TextRenderUtils.getAssetHighlightContent(message.getContent(), UIUtils.getString(R.string.show), !message.isRead()));
        viewUnRead.setVisibility(message.isRead() ? View.GONE : View.VISIBLE);
    }
}
